home *** CD-ROM | disk | FTP | other *** search
/ Inter.Net 55-1 / Inter.Net 55-1.iso / CBuilder / Setup / BCB / data.z / controls.int < prev    next >
Encoding:
Text File  |  1998-02-09  |  28.0 KB  |  786 lines

  1.  
  2. {*******************************************************}
  3. {                                                       }
  4. {       Delphi Visual Component Library                 }
  5. {                                                       }
  6. {       Copyright (c) 1995,98 Borland International     }
  7. {                                                       }
  8. {*******************************************************}
  9.  
  10. unit Controls;
  11.  
  12. {$P+,S-,W-,R-}
  13. {$C PRELOAD}
  14.  
  15. interface
  16.  
  17. {$R CONTROLS}
  18.  
  19. uses Messages, Windows, Classes, Sysutils, Graphics, Menus, CommCtrl, Imm;
  20.  
  21. { CommCtrl.hpp is not required in Controls.hpp }
  22. (*$NOINCLUDE CommCtrl *)
  23.  
  24. { VCL control message IDs }
  25.  
  26. const
  27.   CM_BASE                   = $B000;
  28.   CM_ACTIVATE               = CM_BASE + 0;
  29.   CM_DEACTIVATE             = CM_BASE + 1;
  30.   CM_GOTFOCUS               = CM_BASE + 2;
  31.   CM_LOSTFOCUS              = CM_BASE + 3;
  32.   CM_CANCELMODE             = CM_BASE + 4;
  33.   CM_DIALOGKEY              = CM_BASE + 5;
  34.   CM_DIALOGCHAR             = CM_BASE + 6;
  35.   CM_FOCUSCHANGED           = CM_BASE + 7;
  36.   CM_PARENTFONTCHANGED      = CM_BASE + 8;
  37.   CM_PARENTCOLORCHANGED     = CM_BASE + 9;
  38.   CM_HITTEST                = CM_BASE + 10;
  39.   CM_VISIBLECHANGED         = CM_BASE + 11;
  40.   CM_ENABLEDCHANGED         = CM_BASE + 12;
  41.   CM_COLORCHANGED           = CM_BASE + 13;
  42.   CM_FONTCHANGED            = CM_BASE + 14;
  43.   CM_CURSORCHANGED          = CM_BASE + 15;
  44.   CM_CTL3DCHANGED           = CM_BASE + 16;
  45.   CM_PARENTCTL3DCHANGED     = CM_BASE + 17;
  46.   CM_TEXTCHANGED            = CM_BASE + 18;
  47.   CM_MOUSEENTER             = CM_BASE + 19;
  48.   CM_MOUSELEAVE             = CM_BASE + 20;
  49.   CM_MENUCHANGED            = CM_BASE + 21;
  50.   CM_APPKEYDOWN             = CM_BASE + 22;
  51.   CM_APPSYSCOMMAND          = CM_BASE + 23;
  52.   CM_BUTTONPRESSED          = CM_BASE + 24;
  53.   CM_SHOWINGCHANGED         = CM_BASE + 25;
  54.   CM_ENTER                  = CM_BASE + 26;
  55.   CM_EXIT                   = CM_BASE + 27;
  56.   CM_DESIGNHITTEST          = CM_BASE + 28;
  57.   CM_ICONCHANGED            = CM_BASE + 29;
  58.   CM_WANTSPECIALKEY         = CM_BASE + 30;
  59.   CM_INVOKEHELP             = CM_BASE + 31;
  60.   CM_WINDOWHOOK             = CM_BASE + 32;
  61.   CM_RELEASE                = CM_BASE + 33;
  62.   CM_SHOWHINTCHANGED        = CM_BASE + 34;
  63.   CM_PARENTSHOWHINTCHANGED  = CM_BASE + 35;
  64.   CM_SYSCOLORCHANGE         = CM_BASE + 36;
  65.   CM_WININICHANGE           = CM_BASE + 37;
  66.   CM_FONTCHANGE             = CM_BASE + 38;
  67.   CM_TIMECHANGE             = CM_BASE + 39;
  68.   CM_TABSTOPCHANGED         = CM_BASE + 40;
  69.   CM_UIACTIVATE             = CM_BASE + 41;
  70.   CM_UIDEACTIVATE           = CM_BASE + 42;
  71.   CM_DOCWINDOWACTIVATE      = CM_BASE + 43;
  72.   CM_CONTROLLISTCHANGE      = CM_BASE + 44;
  73.   CM_GETDATALINK            = CM_BASE + 45;
  74.   CM_CHILDKEY               = CM_BASE + 46;
  75.   CM_DRAG                   = CM_BASE + 47;
  76.   CM_HINTSHOW               = CM_BASE + 48;
  77.   CM_DIALOGHANDLE           = CM_BASE + 49;
  78.   CM_ISTOOLCONTROL          = CM_BASE + 50;
  79.   CM_RECREATEWND            = CM_BASE + 51;
  80.   CM_INVALIDATE             = CM_BASE + 52;
  81.   CM_SYSFONTCHANGED         = CM_BASE + 53;
  82.   CM_CONTROLCHANGE          = CM_BASE + 54;
  83.   CM_CHANGED                = CM_BASE + 55;
  84.  
  85. { VCL control notification IDs }
  86.  
  87. const
  88.   CN_BASE              = $BC00;
  89.   CN_CHARTOITEM        = CN_BASE + WM_CHARTOITEM;
  90.   CN_COMMAND           = CN_BASE + WM_COMMAND;
  91.   CN_COMPAREITEM       = CN_BASE + WM_COMPAREITEM;
  92.   CN_CTLCOLORBTN       = CN_BASE + WM_CTLCOLORBTN;
  93.   CN_CTLCOLORDLG       = CN_BASE + WM_CTLCOLORDLG;
  94.   CN_CTLCOLOREDIT      = CN_BASE + WM_CTLCOLOREDIT;
  95.   CN_CTLCOLORLISTBOX   = CN_BASE + WM_CTLCOLORLISTBOX;
  96.   CN_CTLCOLORMSGBOX    = CN_BASE + WM_CTLCOLORMSGBOX;
  97.   CN_CTLCOLORSCROLLBAR = CN_BASE + WM_CTLCOLORSCROLLBAR;
  98.   CN_CTLCOLORSTATIC    = CN_BASE + WM_CTLCOLORSTATIC;
  99.   CN_DELETEITEM        = CN_BASE + WM_DELETEITEM;
  100.   CN_DRAWITEM          = CN_BASE + WM_DRAWITEM;
  101.   CN_HSCROLL           = CN_BASE + WM_HSCROLL;
  102.   CN_MEASUREITEM       = CN_BASE + WM_MEASUREITEM;
  103.   CN_PARENTNOTIFY      = CN_BASE + WM_PARENTNOTIFY;
  104.   CN_VKEYTOITEM        = CN_BASE + WM_VKEYTOITEM;
  105.   CN_VSCROLL           = CN_BASE + WM_VSCROLL;
  106.   CN_KEYDOWN           = CN_BASE + WM_KEYDOWN;
  107.   CN_KEYUP             = CN_BASE + WM_KEYUP;
  108.   CN_CHAR              = CN_BASE + WM_CHAR;
  109.   CN_SYSKEYDOWN        = CN_BASE + WM_SYSKEYDOWN;
  110.   CN_SYSCHAR           = CN_BASE + WM_SYSCHAR;
  111.   CN_NOTIFY            = CN_BASE + WM_NOTIFY;
  112.  
  113. { TModalResult values }
  114.  
  115. const
  116.   mrNone     = 0;
  117.   mrOk       = idOk;
  118.   mrCancel   = idCancel;
  119.   mrAbort    = idAbort;
  120.   mrRetry    = idRetry;
  121.   mrIgnore   = idIgnore;
  122.   mrYes      = idYes;
  123.   mrNo       = idNo;
  124.   mrAll      = mrNo + 1;
  125.   mrNoToAll  = mrAll + 1;
  126.   mrYesToAll = mrNoToAll + 1;
  127.  
  128. { Cursor identifiers }
  129.  
  130. type
  131.   TCursor = -32768..32767;
  132.   {$NODEFINE TCursor}
  133.  
  134.   (*$HPPEMIT 'namespace Controls' *)
  135.   (*$HPPEMIT '{' *)
  136.     (*$HPPEMIT 'enum TCursor' *)
  137.     (*$HPPEMIT '{' *)
  138.         (*$HPPEMIT 'crDefault     =  0, ' *)
  139.         (*$HPPEMIT 'crNone        = -1, ' *)
  140.         (*$HPPEMIT 'crArrow       = -2, ' *)
  141.         (*$HPPEMIT 'crCross       = -3, ' *)
  142.         (*$HPPEMIT 'crIBeam       = -4, ' *)
  143.         (*$HPPEMIT 'crSize        = -5, ' *)
  144.         (*$HPPEMIT 'crSizeNESW    = -6, ' *)
  145.         (*$HPPEMIT 'crSizeNS      = -7, ' *)
  146.         (*$HPPEMIT 'crSizeNWSE    = -8, ' *)
  147.         (*$HPPEMIT 'crSizeWE      = -9, ' *)
  148.         (*$HPPEMIT 'crUpArrow     = -10,' *)
  149.         (*$HPPEMIT 'crHourGlass   = -11,' *)
  150.         (*$HPPEMIT 'crDrag        = -12,' *)
  151.         (*$HPPEMIT 'crNoDrop      = -13,' *)
  152.         (*$HPPEMIT 'crHSplit      = -14,' *)
  153.         (*$HPPEMIT 'crVSplit      = -15,' *)
  154.         (*$HPPEMIT 'crMultiDrag   = -16,' *)
  155.         (*$HPPEMIT 'crSQLWait     = -17,' *)
  156.         (*$HPPEMIT 'crNo          = -18,' *)
  157.         (*$HPPEMIT 'crAppStart    = -19,' *)
  158.         (*$HPPEMIT 'crHelp        = -20,' *)
  159.         (*$HPPEMIT 'crHandPoint   = -21,' *)
  160.         (*$HPPEMIT 'crSizeAll     = -22,' *)
  161.         (*$HPPEMIT 'crMax         = 0x7FFF'*)
  162.     (*$HPPEMIT '};' *)
  163.   (*$HPPEMIT '}' *)
  164.  
  165. const
  166.   crDefault     = TCursor(0);
  167.   crNone        = TCursor(-1);
  168.   crArrow       = TCursor(-2);
  169.   crCross       = TCursor(-3);
  170.   crIBeam       = TCursor(-4);
  171.   crSize        = TCursor(-5);
  172.   crSizeNESW    = TCursor(-6);
  173.   crSizeNS      = TCursor(-7);
  174.   crSizeNWSE    = TCursor(-8);
  175.   crSizeWE      = TCursor(-9);
  176.   crUpArrow     = TCursor(-10);
  177.   crHourGlass   = TCursor(-11);
  178.   crDrag        = TCursor(-12);
  179.   crNoDrop      = TCursor(-13);
  180.   crHSplit      = TCursor(-14);
  181.   crVSplit      = TCursor(-15);
  182.   crMultiDrag   = TCursor(-16);
  183.   crSQLWait     = TCursor(-17);
  184.   crNo          = TCursor(-18);
  185.   crAppStart    = TCursor(-19);
  186.   crHelp        = TCursor(-20);
  187.   crHandPoint   = TCursor(-21);
  188.   crSizeAll     = TCursor(-22);
  189.  
  190. type
  191.  
  192. { Forward declarations }
  193.  
  194.   TDragObject = class;
  195.   TControl = class;
  196.   TWinControl = class;
  197.   TCustomImageList = class;
  198.  
  199. { VCL control message records }
  200.  
  201.   TCMActivate = TWMNoParams;
  202.   TCMDeactivate = TWMNoParams;
  203.   TCMGotFocus = TWMNoParams;
  204.   TCMLostFocus = TWMNoParams;
  205.   TCMDialogKey = TWMKey;
  206.   TCMDialogChar = TWMKey;
  207.   TCMHitTest = TWMNCHitTest;
  208.   TCMEnter = TWMNoParams;
  209.   TCMExit = TWMNoParams;
  210.   TCMDesignHitTest = TWMMouse;
  211.   TCMWantSpecialKey = TWMKey;
  212.  
  213.   TCMCancelMode = record
  214.     Msg: Cardinal;
  215.     Unused: Integer;
  216.     Sender: TControl;
  217.     Result: Longint;
  218.   end;
  219.  
  220.   TCMFocusChanged = record
  221.     Msg: Cardinal;
  222.     Unused: Integer;
  223.     Sender: TWinControl;
  224.     Result: Longint;
  225.   end;
  226.  
  227.   TCMControlListChange = record
  228.     Msg: Cardinal;
  229.     Control: TControl;
  230.     Inserting: LongBool;
  231.     Result: Longint;
  232.   end;
  233.  
  234.   TCMChildKey = record
  235.     Msg: Cardinal;
  236.     CharCode: Word;
  237.     Unused: Word;
  238.     Sender: TWinControl;
  239.     Result: Longint;
  240.   end;
  241.  
  242.   TCMControlChange = record
  243.     Msg: Cardinal;
  244.     Control: TControl;
  245.     Inserting: LongBool;
  246.     Result: Longint;
  247.   end;
  248.  
  249.   TCMChanged = record
  250.     Msg: Cardinal;
  251.     Unused: Longint;
  252.     Child: TControl;
  253.     Result: Longint;
  254.   end;
  255.  
  256.   TDragMessage = (dmDragEnter, dmDragLeave, dmDragMove, dmDragDrop, dmDragCancel,
  257.     dmFindTarget);
  258.  
  259.   PDragRec = ^TDragRec;
  260.   TDragRec = record
  261.     Pos: TPoint;
  262.     Source: TDragObject;
  263.     Target: Pointer;
  264.   end;
  265.  
  266.   TCMDrag = packed record
  267.     Msg: Cardinal;
  268.     DragMessage: TDragMessage;
  269.     Reserved1: Byte;
  270.     Reserved2: Word;
  271.     DragRec: PDragRec;
  272.     Result: Longint;
  273.   end;
  274.  
  275. { Dragging objects }
  276.  
  277.   TDragObject = class(TObject)
  278.   protected
  279.     function GetDragImages: TCustomImageList; virtual;
  280.     function GetDragCursor(Accepted: Boolean; X, Y: Integer): TCursor; virtual;
  281.     procedure Finished(Target: TObject; X, Y: Integer; Accepted: Boolean); virtual;
  282.   public
  283.     function Instance: THandle; virtual;
  284.     function GetName: string; virtual;
  285.     procedure HideDragImage; virtual;
  286.     procedure ShowDragImage; virtual;
  287.   end;
  288.  
  289.   TDragControlObject = class(TDragObject)
  290.   protected
  291.     function GetDragImages: TCustomImageList; override;
  292.     function GetDragCursor(Accepted: Boolean; X, Y: Integer): TCursor; override;
  293.     procedure Finished(Target: TObject; X, Y: Integer; Accepted: Boolean); override;
  294.   public
  295.     constructor Create(AControl: TControl);
  296.     property Control: TControl;
  297.     procedure HideDragImage; override;
  298.     procedure ShowDragImage; override;
  299.   end;
  300.  
  301. { Controls }
  302.  
  303.   TControlCanvas = class(TCanvas)
  304.   protected
  305.     procedure CreateHandle; override;
  306.   public
  307.     destructor Destroy; override;
  308.     procedure FreeHandle;
  309.     property Control: TControl;
  310.   end;
  311.  
  312.   TAlign = (alNone, alTop, alBottom, alLeft, alRight, alClient);
  313.  
  314.   TControlState = set of (csLButtonDown, csClicked, csPalette,
  315.     csReadingState, csAlignmentNeeded, csFocusing, csCreating,
  316.     csPaintCopy);
  317.  
  318.   TControlStyle = set of (csAcceptsControls, csCaptureMouse,
  319.     csDesignInteractive, csClickEvents, csFramed, csSetCaption, csOpaque,
  320.     csDoubleClicks, csFixedWidth, csFixedHeight, csNoDesignVisible,
  321.     csReplicatable, csNoStdEvents, csDisplayDragImage, csReflector);
  322.  
  323.   TMouseButton = (mbLeft, mbRight, mbMiddle);
  324.  
  325.   TDragMode = (dmManual, dmAutomatic);
  326.  
  327.   TDragState = (dsDragEnter, dsDragLeave, dsDragMove);
  328.  
  329.   TTabOrder = -1..32767;
  330.  
  331.   TCaption = type string;
  332.  
  333.   TDate = type TDateTime;
  334.  
  335.   TTime = type TDateTime;
  336.   {$EXTERNALSYM TDate}
  337.   {$EXTERNALSYM TTime}
  338.  
  339.   TScalingFlags = set of (sfLeft, sfTop, sfWidth, sfHeight, sfFont);
  340.  
  341.   TMouseEvent = procedure(Sender: TObject; Button: TMouseButton;
  342.     Shift: TShiftState; X, Y: Integer) of object;
  343.   TMouseMoveEvent = procedure(Sender: TObject; Shift: TShiftState;
  344.     X, Y: Integer) of object;
  345.   TKeyEvent = procedure(Sender: TObject; var Key: Word;
  346.     Shift: TShiftState) of object;
  347.   TKeyPressEvent = procedure(Sender: TObject; var Key: Char) of object;
  348.   TDragOverEvent = procedure(Sender, Source: TObject; X, Y: Integer;
  349.     State: TDragState; var Accept: Boolean) of object;
  350.   TDragDropEvent = procedure(Sender, Source: TObject;
  351.     X, Y: Integer) of object;
  352.   TStartDragEvent = procedure(Sender: TObject;
  353.     var DragObject: TDragObject) of object;
  354.   TEndDragEvent = procedure(Sender, Target: TObject;
  355.     X, Y: Integer) of object;
  356.  
  357.   TWndMethod = procedure(var Message: TMessage) of object;
  358.  
  359.   TControl = class(TComponent)
  360.   protected
  361.     procedure Changed;
  362.     procedure ChangeScale(M, D: Integer); dynamic;
  363.     procedure Click; dynamic;
  364.     procedure DblClick; dynamic;
  365.     procedure DefaultHandler(var Message); override;
  366.     procedure DefineProperties(Filer: TFiler); override;
  367.     procedure DragCanceled; dynamic;
  368.     procedure DragOver(Source: TObject; X, Y: Integer; State: TDragState;
  369.       var Accept: Boolean); dynamic;
  370.     procedure DoEndDrag(Target: TObject; X, Y: Integer); dynamic;
  371.     procedure DoStartDrag(var DragObject: TDragObject); dynamic;
  372.     function GetClientOrigin: TPoint; virtual;
  373.     function GetClientRect: TRect; virtual;
  374.     function GetDeviceContext(var WindowHandle: HWnd): HDC; virtual;
  375.     function GetDragImages: TCustomImageList; virtual;
  376.     function GetPalette: HPALETTE; dynamic;
  377.     function GetParentComponent: TComponent; override;
  378.     function GetPopupMenu: TPopupMenu; dynamic;
  379.     function HasParent: Boolean; override;
  380.     procedure MouseDown(Button: TMouseButton; Shift: TShiftState;
  381.       X, Y: Integer); dynamic;
  382.     procedure MouseMove(Shift: TShiftState; X, Y: Integer); dynamic;
  383.     procedure MouseUp(Button: TMouseButton; Shift: TShiftState;
  384.       X, Y: Integer); dynamic;
  385.     procedure Notification(AComponent: TComponent;
  386.       Operation: TOperation); override;
  387.     function PaletteChanged(Foreground: Boolean): Boolean; dynamic;
  388.     procedure ReadState(Reader: TReader); override;
  389.     procedure RequestAlign; dynamic;
  390.     procedure SendCancelMode(Sender: TControl);
  391.     procedure SetDragMode(Value: TDragMode); virtual;
  392.     procedure SetParent(AParent: TWinControl); virtual;
  393.     procedure SetParentComponent(Value: TComponent); override;
  394.     procedure SetName(const Value: TComponentName); override;
  395.     procedure SetZOrder(TopMost: Boolean); dynamic;
  396.     procedure UpdateBoundsRect(const R: TRect);
  397.     procedure VisibleChanging; dynamic;
  398.     procedure WndProc(var Message: TMessage); virtual;
  399.     property Caption: TCaption;
  400.     property Color: TColor default clWindow;
  401.     property DesktopFont: Boolean default False;
  402.     property DragCursor: TCursor default crDrag;
  403.     property DragMode: TDragMode default dmManual;
  404.     property Font: TFont;
  405.     property IsControl: Boolean;
  406.     property MouseCapture: Boolean;
  407.     property ParentColor: Boolean default True;
  408.     property ParentFont: Boolean default True;
  409.     property ParentShowHint: Boolean default True;
  410.     property PopupMenu: TPopupMenu;
  411.     property ScalingFlags: TScalingFlags;
  412.     property Text: TCaption;
  413.     property WindowText: PChar;
  414.     property OnClick: TNotifyEvent;
  415.     property OnDblClick: TNotifyEvent;
  416.     property OnDragDrop: TDragDropEvent;
  417.     property OnDragOver: TDragOverEvent;
  418.     property OnEndDrag: TEndDragEvent;
  419.     property OnMouseDown: TMouseEvent;
  420.     property OnMouseMove: TMouseMoveEvent;
  421.     property OnMouseUp: TMouseEvent;
  422.     property OnStartDrag: TStartDragEvent;
  423.   public
  424.     constructor Create(AOwner: TComponent); override;
  425.     destructor Destroy; override;
  426.     procedure BeginDrag(Immediate: Boolean);
  427.     procedure BringToFront;
  428.     function ClientToScreen(const Point: TPoint): TPoint;
  429.     function Dragging: Boolean;
  430.     procedure DragDrop(Source: TObject; X, Y: Integer); dynamic;
  431.     procedure EndDrag(Drop: Boolean);
  432.     function GetTextBuf(Buffer: PChar; BufSize: Integer): Integer;
  433.     function GetTextLen: Integer;
  434.     procedure Hide;
  435.     procedure Invalidate; virtual;
  436.     function Perform(Msg: Cardinal; WParam, LParam: Longint): Longint;
  437.     procedure Refresh;
  438.     procedure Repaint; virtual;
  439.     function ScreenToClient(const Point: TPoint): TPoint;
  440.     procedure SendToBack;
  441.     procedure SetBounds(ALeft, ATop, AWidth, AHeight: Integer); virtual;
  442.     procedure SetTextBuf(Buffer: PChar);
  443.     procedure Show;
  444.     procedure Update; virtual;
  445.     property Align: TAlign default alNone;
  446.     property BoundsRect: TRect;
  447.     property ClientHeight: Integer;
  448.     property ClientOrigin: TPoint;
  449.     property ClientRect: TRect;
  450.     property ClientWidth: Integer;
  451.     property ControlState: TControlState;
  452.     property ControlStyle: TControlStyle;
  453.     property Parent: TWinControl;
  454.     property ShowHint: Boolean;
  455.     property Visible: Boolean default True;
  456.     property Enabled: Boolean default True;
  457.     property WindowProc: TWndMethod;
  458.   published
  459.     property Left: Integer;
  460.     property Top: Integer;
  461.     property Width: Integer;
  462.     property Height: Integer;
  463.     property Cursor: TCursor default crDefault;
  464.     property Hint: string;
  465.   end;
  466.  
  467.   TControlClass = class of TControl;
  468.  
  469.   TCreateParams = record
  470.     Caption: PChar;
  471.     Style: Longint;
  472.     ExStyle: Longint;
  473.     X, Y: Integer;
  474.     Width, Height: Integer;
  475.     WndParent: HWnd;
  476.     Param: Pointer;
  477.     WindowClass: TWndClass;
  478.     WinClassName: array[0..63] of Char;
  479.   end;
  480.  
  481.   TImeMode = (imDisable, imClose, imOpen, imDontCare,
  482.               imSAlpha, imAlpha, imHira, imSKata, imKata,
  483.               imChinese, imSHanguel, imHanguel);
  484.   TImeName = type string;
  485.  
  486.   TWinControl = class(TControl)
  487.   protected
  488.     FDoubleBuffered: Boolean;
  489.     FInImeComposition: Boolean;
  490.     procedure AlignControls(AControl: TControl; var Rect: TRect); virtual;
  491.     procedure ChangeScale(M, D: Integer); override;
  492.     procedure CreateHandle; virtual;
  493.     procedure CreateParams(var Params: TCreateParams); virtual;
  494.     procedure CreateSubClass(var Params: TCreateParams;
  495.       ControlClassName: PChar);
  496.     procedure CreateWindowHandle(const Params: TCreateParams); virtual;
  497.     procedure CreateWnd; virtual;
  498.     procedure DefaultHandler(var Message); override;
  499.     procedure DestroyHandle;
  500.     procedure DestroyWindowHandle; virtual;
  501.     procedure DestroyWnd; virtual;
  502.     procedure DoEnter; dynamic;
  503.     procedure DoExit; dynamic;
  504.     function DoKeyDown(var Message: TWMKey): Boolean;
  505.     function DoKeyPress(var Message: TWMKey): Boolean;
  506.     function DoKeyUp(var Message: TWMKey): Boolean;
  507.     function FindNextControl(CurControl: TWinControl;
  508.       GoForward, CheckTabStop, CheckParent: Boolean): TWinControl;
  509.     procedure FixupTabList;
  510.     procedure GetChildren(Proc: TGetChildProc; Root: TComponent); override;
  511.     function GetClientOrigin: TPoint; override;
  512.     function GetClientRect: TRect; override;
  513.     function GetDeviceContext(var WindowHandle: HWnd): HDC; override;
  514.     function GetParentHandle: HWnd;
  515.     function GetTopParentHandle: HWnd;
  516.     function IsControlMouseMsg(var Message: TWMMouse): Boolean;
  517.     procedure KeyDown(var Key: Word; Shift: TShiftState); dynamic;
  518.     procedure KeyUp(var Key: Word; Shift: TShiftState); dynamic;
  519.     procedure KeyPress(var Key: Char); dynamic;
  520.     procedure MainWndProc(var Message: TMessage);
  521.     procedure NotifyControls(Msg: Word);
  522.     procedure PaintControls(DC: HDC; First: TControl);
  523.     procedure PaintHandler(var Message: TWMPaint);
  524.     procedure PaintWindow(DC: HDC); virtual;
  525.     function PaletteChanged(Foreground: Boolean): Boolean; override;
  526.     procedure ReadState(Reader: TReader); override;
  527.     procedure RecreateWnd;
  528.     procedure ResetIme;
  529.     function ResetImeComposition(Action: DWORD): Boolean;
  530.     procedure ScaleControls(M, D: Integer);
  531.     procedure SelectFirst;
  532.     procedure SelectNext(CurControl: TWinControl;
  533.       GoForward, CheckTabStop: Boolean);
  534.     procedure SetChildOrder(Child: TComponent; Order: Integer); override;
  535.     procedure SetIme;
  536.     function SetImeCompositionWindow(Font: TFont; XPos, YPos: Integer): Boolean;
  537.     procedure SetZOrder(TopMost: Boolean); override;
  538.     procedure ShowControl(AControl: TControl); virtual;
  539.     procedure WndProc(var Message: TMessage); override;
  540.     property Ctl3D: Boolean;
  541.     property DefWndProc: Pointer;
  542.     property ImeMode: TImeMode default imDontCare;
  543.     property ImeName: TImeName;
  544.     property ParentCtl3D: Boolean default True;
  545.     property WindowHandle: HWnd;
  546.     property OnEnter: TNotifyEvent;
  547.     property OnExit: TNotifyEvent;
  548.     property OnKeyDown: TKeyEvent;
  549.     property OnKeyPress: TKeyPressEvent;
  550.     property OnKeyUp: TKeyEvent;
  551.   public
  552.     constructor Create(AOwner: TComponent); override;
  553.     constructor CreateParented(ParentWindow: HWnd);
  554.     // jmt.  Change to integer to work around managled name mismatch
  555.     // when called from BCB.  Change back to Hwnd when a thunk
  556.     // is added to BCB.
  557.     class function CreateParentedControl(ParentWindow: Integer): TWinControl;
  558.     destructor Destroy; override;
  559.     procedure Broadcast(var Message);
  560.     function CanFocus: Boolean;
  561.     function ContainsControl(Control: TControl): Boolean;
  562.     function ControlAtPos(const Pos: TPoint; AllowDisabled: Boolean): TControl;
  563.     procedure DisableAlign;
  564.     procedure EnableAlign;
  565.     function Focused: Boolean;
  566.     procedure GetTabOrderList(List: TList); dynamic;
  567.     function HandleAllocated: Boolean;
  568.     procedure HandleNeeded;
  569.     procedure InsertControl(AControl: TControl);
  570.     procedure Invalidate; override;
  571.     procedure PaintTo(DC: HDC; X, Y: Integer);
  572.     procedure RemoveControl(AControl: TControl);
  573.     procedure Realign;
  574.     procedure Repaint; override;
  575.     procedure ScaleBy(M, D: Integer);
  576.     procedure ScrollBy(DeltaX, DeltaY: Integer);
  577.     procedure SetBounds(ALeft, ATop, AWidth, AHeight: Integer); override;
  578.     procedure SetFocus; virtual;
  579.     procedure Update; override;
  580.     procedure UpdateControlState;
  581.     property Brush: TBrush;
  582.     property Controls[Index: Integer]: TControl;
  583.     property ControlCount: Integer;
  584.     property Handle: HWnd;
  585.     property ParentWindow: HWnd;
  586.     property Showing: Boolean;
  587.     property TabOrder: TTabOrder default -1;
  588.     property TabStop: Boolean default False;
  589.   published
  590.     property HelpContext: THelpContext default 0;
  591.   end;
  592.  
  593.   TWinControlClass = class of TWinControl;
  594.  
  595.   TGraphicControl = class(TControl)
  596.   protected
  597.     procedure Paint; virtual;
  598.     property Canvas: TCanvas;
  599.   public
  600.     constructor Create(AOwner: TComponent); override;
  601.     destructor Destroy; override;
  602.   end;
  603.  
  604.   TCustomControl = class(TWinControl)
  605.   protected
  606.     procedure Paint; virtual;
  607.     procedure PaintWindow(DC: HDC); override;
  608.     property Canvas: TCanvas;
  609.   public
  610.     constructor Create(AOwner: TComponent); override;
  611.     destructor Destroy; override;
  612.   end;
  613.  
  614.   THintWindow = class(TCustomControl)
  615.   protected
  616.     procedure CreateParams(var Params: TCreateParams); override;
  617.     procedure Paint; override;
  618.   public
  619.     constructor Create(AOwner: TComponent); override;
  620.     procedure ActivateHint(Rect: TRect; const AHint: string); virtual;
  621.     procedure ActivateHintData(Rect: TRect; const AHint: string; AData: Pointer); virtual;
  622.     function CalcHintRect(MaxWidth: Integer; const AHint: string;
  623.       AData: Pointer): TRect; virtual;
  624.     function IsHintMsg(var Msg: TMsg): Boolean; virtual;
  625.     procedure ReleaseHandle;
  626.     property Caption;
  627.     property Color;
  628.     property Canvas;
  629.   end;
  630.  
  631.   THintWindowClass = class of THintWindow;
  632.  
  633. { TChangeLink }
  634.  
  635.   TChangeLink = class(TObject)
  636.   public
  637.     destructor Destroy; override;
  638.     procedure Change; dynamic;
  639.     property OnChange: TNotifyEvent;
  640.     property Sender: TCustomImageList;
  641.   end;
  642.  
  643.   { TCustomImageList }
  644.  
  645.   TDrawingStyle = (dsFocus, dsSelected, dsNormal, dsTransparent);
  646.   TImageType = (itImage, itMask);
  647.   TResType = (rtBitmap, rtCursor, rtIcon);
  648.   TOverlay = 0..3;
  649.   TLoadResource = (lrDefaultColor, lrDefaultSize, lrFromFile,
  650.     lrMap3DColors, lrTransparent, lrMonoChrome);
  651.   TLoadResources = set of TLoadResource;
  652.  
  653.   TCustomImageList = class(TComponent)
  654.   protected
  655.     procedure Change; dynamic;
  656.     procedure DefineProperties(Filer: TFiler); override;
  657.     procedure GetImages(Index: Integer; Image, Mask: TBitmap);
  658.     procedure HandleNeeded;
  659.     procedure Initialize;
  660.     property BlendColor: TColor default clNone;
  661.     property BkColor: TColor default clNone;
  662.     property AllocBy: Integer default 4;
  663.     property DrawingStyle: TDrawingStyle default dsNormal;
  664.     property Height: Integer default 16;
  665.     property ImageType: TImageType default itImage;
  666.     property Masked: Boolean default True;
  667.     property OnChange: TNotifyEvent;
  668.     property ShareImages: Boolean default False;
  669.     property Width: Integer default 16;
  670.   public
  671.     constructor Create(AOwner: TComponent); override;
  672.     constructor CreateSize(AWidth, AHeight: Integer);
  673.     destructor Destroy; override;
  674.     procedure Assign(Source: TPersistent); override;
  675.     function Add(Image, Mask: TBitmap): Integer;
  676.     function AddIcon(Image: TIcon): Integer;
  677.     procedure AddImages(Value: TCustomImageList);
  678.     function AddMasked(Image: TBitmap; MaskColor: TColor): Integer;
  679.     function BeginDrag(Window: HWND; X, Y: Integer): Boolean;
  680.     procedure Clear;
  681.     procedure Delete(Index: Integer);
  682.     function DragLock(Window: HWND; XPos, YPos: Integer): Boolean;
  683.     function DragMove(X, Y: Integer): Boolean;
  684.     procedure DragUnlock;
  685.     procedure Draw(Canvas: TCanvas; X, Y, Index: Integer);
  686.     procedure DrawOverlay(Canvas: TCanvas; X, Y: Integer;
  687.       ImageIndex: Integer; Overlay: TOverlay);
  688.     function EndDrag: Boolean;
  689.     function FileLoad(ResType: TResType; Name: string;
  690.       MaskColor: TColor): Boolean;
  691.     procedure GetBitmap(Index: Integer; Image: TBitmap);
  692.     function GetHotSpot: TPoint;
  693.     procedure GetIcon(Index: Integer; Image: TIcon);
  694.     function GetImageBitmap: HBITMAP;
  695.     function GetMaskBitmap: HBITMAP;
  696.     function GetResource(ResType: TResType; Name: string;
  697.       Width: Integer; LoadFlags: TLoadResources; MaskColor: TColor): Boolean;
  698.     function GetInstRes(Instance: THandle; ResType: TResType; Name: string;
  699.       Width: Integer; LoadFlags: TLoadResources; MaskColor: TColor): Boolean;
  700.     function HandleAllocated: Boolean;
  701.     procedure HideDragImage;
  702.     procedure Insert(Index: Integer; Image, Mask: TBitmap);
  703.     procedure InsertIcon(Index: Integer; Image: TIcon);
  704.     procedure InsertMasked(Index: Integer; Image: TBitmap; MaskColor: TColor);
  705.     procedure Move(CurIndex, NewIndex: Integer);
  706.     function Overlay(ImageIndex: Integer; Overlay: TOverlay): Boolean;
  707.     procedure RegisterChanges(Value: TChangeLink);
  708.     function ResourceLoad(ResType: TResType; Name: string;
  709.       MaskColor: TColor): Boolean;
  710.     function ResInstLoad(Instance: THandle; ResType: TResType; Name: string;
  711.       MaskColor: TColor): Boolean;
  712.     procedure Replace(Index: Integer; Image, Mask: TBitmap);
  713.     procedure ReplaceIcon(Index: Integer; Image: TIcon);
  714.     procedure ReplaceMasked(Index: Integer; NewImage: TBitmap; MaskColor: TColor);
  715.     function SetDragImage(Index, HotSpotX, HotSpotY: Integer): Boolean;
  716.     procedure ShowDragImage;
  717.     procedure UnRegisterChanges(Value: TChangeLink);
  718.     property Count: Integer;
  719.     property DragCursor: TCursor;
  720.     property Dragging: Boolean;
  721.     property Handle: HImageList;
  722.   end;
  723.  
  724. { TImageList }
  725.   TImageList = class(TCustomImageList)
  726.   published
  727.     property BlendColor;
  728.     property BkColor;
  729.     property AllocBy;
  730.     property DrawingStyle;
  731.     property Height;
  732.     property ImageType;
  733.     property Masked;
  734.     property OnChange;
  735.     property ShareImages;
  736.     property Width;
  737.   end;
  738.  
  739. function IsDragObject(Sender: TObject): Boolean;
  740. function FindControl(Handle: HWnd): TWinControl;
  741. function FindVCLWindow(const Pos: TPoint): TWinControl;
  742. function FindDragTarget(const Pos: TPoint; AllowDisabled: Boolean): TControl;
  743. function GetCaptureControl: TControl;
  744. procedure SetCaptureControl(Control: TControl);
  745. procedure CancelDrag;
  746.  
  747. function CursorToString(Cursor: TCursor): string;
  748. function StringToCursor(const S: string): TCursor;
  749. procedure GetCursorValues(Proc: TGetStrProc);
  750. function CursorToIdent(Cursor: Longint; var Ident: string): Boolean;
  751. function IdentToCursor(const Ident: string; var Cursor: Longint): Boolean;
  752.  
  753. function GetShortHint(const Hint: string): string;
  754. function GetLongHint(const Hint: string): string;
  755.  
  756. var
  757.   CreationControl: TWinControl = nil;
  758.  
  759. function InitWndProc(HWindow: HWnd; Message, WParam: Longint;
  760.   LParam: Longint): Longint; stdcall;
  761.  
  762. const
  763.   CTL3D_ALL = $FFFF;
  764.  
  765. var
  766.   NewStyleControls: Boolean;
  767.  
  768. function SendAppMessage(Msg: Cardinal; WParam, LParam: Longint): Longint;
  769. procedure MoveWindowOrg(DC: HDC; DX, DY: Integer);
  770.  
  771. procedure SetImeMode(hWnd: HWND; Mode: TImeMode);
  772. procedure SetImeName(Name: TImeName);
  773. function Win32NLSEnableIME(hWnd: HWND; Enable: Boolean): Boolean;
  774. function Imm32GetContext(hWnd: HWND): HIMC;
  775. function Imm32ReleaseContext(hWnd: HWND; hImc: HIMC): Boolean;
  776. function Imm32GetConversionStatus(hImc: HIMC; var Conversion, Sentence: DWORD): Boolean;
  777. function Imm32SetConversionStatus(hImc: HIMC; Conversion, Sentence: DWORD): Boolean;
  778. function Imm32SetOpenStatus(hImc: HIMC; fOpen: Boolean): Boolean;
  779. function Imm32SetCompositionWindow(hImc: HIMC; lpCompForm: PCOMPOSITIONFORM): Boolean;
  780. function Imm32SetCompositionFont(hImc: HIMC; lpLogfont: PLOGFONTA): Boolean;
  781. function Imm32GetCompositionString(hImc: HIMC; dWord1: DWORD; lpBuf: pointer; dwBufLen: DWORD): Longint;
  782. function Imm32IsIME(hKl: HKL): Boolean;
  783. function Imm32NotifyIME(hImc: HIMC; dwAction, dwIndex, dwValue: DWORD): Boolean;
  784.  
  785. implementation
  786.